﻿using System;
using System.Collections.Generic;
using Web7.Core.Apps;
using Web7.Core.Security;

namespace Web7.Container
{
    public class Permissions : IPermissionProvider
    {
        public static readonly Permission ManageUser = new Permission() { Description = "User View", Name = "UserView", ActionName = "Index", FeatureName = "Web7.Container", Id = new Guid("D3AA6D85-95C7-40C0-B7F1-D359F4188870") };

        public static readonly Permission UserCreate = new Permission() { Description = "User Create", Name = "UserCreate", ActionName = "Create", FeatureName = "Web7.Container", Id = new Guid("5026D9DD-F64A-4F3E-8F86-B06B202B537F") };

        public static readonly Permission UserEdit = new Permission() { Description = "User Edit", Name = "UserEdit", ActionName = "Edit", FeatureName = "Web7.Container", Id = new Guid("7B4E57CB-D28D-4617-8A82-C2A2F4F7F91D") };

        public static readonly Permission UserDelete = new Permission() { Description = "User Delete", Name = "UserDelete", ActionName = "Delete", FeatureName = "Web7.Container", Id = new Guid("EEF40FFD-7E21-475A-AFE9-5C6D4495D910") };

        public static readonly Permission ManageRole = new Permission() { Description = "Role View", Name = "RoleView", ActionName = "Index", FeatureName = "Web7.Container", Id = new Guid("A3C79606-61C0-45C8-BC76-C96CE7E8760B") };

        public static readonly Permission RoleCreate = new Permission() { Description = "Role Create", Name = "RoleCreate", ActionName = "Create", FeatureName = "Web7.Container", Id = new Guid("83B12C80-32ED-4708-A996-8C5495313EB1") };

        public static readonly Permission RoleEdit = new Permission() { Description = "Role Edit", Name = "RoleEdit", ActionName = "Edit", FeatureName = "Web7.Container", Id = new Guid("1E4F1474-EC41-4923-BCB6-89FDB0B20240") };

        public static readonly Permission RoleDelete = new Permission() { Description = "Role Delete", Name = "RoleDelete", ActionName = "Delete", FeatureName = "Web7.Container", Id = new Guid("FC8032AE-A7B5-4A99-8A8C-BE840416C0A7") };

        public static readonly Permission PermissionRecords = new Permission() { Description = "Permission Records", Name = "PermissionRecords", ActionName = "Index", FeatureName = "Web7.Container", Id = new Guid("1F2569E8-E206-48C8-9D72-84BC27D74ABD") };

        public List<AppMenuItem> GetAppMenus()
        {
            return new List<AppMenuItem>()
            {
                new AppMenuItem()
                {
                    Title = "用户管理",
                    ContentRouteName = "",
                    Permission = "ManageAccount",
                    SubMenuRouteName = ""
                },
                new AppMenuItem()
                {
                    Title = "用户创建",
                    ContentRouteName = "",
                    Permission = "AccountCreate",
                    SubMenuRouteName = ""
                },
                new AppMenuItem()
                {
                    Title = "权限列表",
                    ContentRouteName = "",
                    Permission = "PermissionRecords",
                    SubMenuRouteName = ""
                }
            };
        }

        public IEnumerable<Permission> GetPermissions()
        {
            return new[] 
            {
                ManageUser,
                UserCreate,
                UserDelete,
                UserEdit,
                ManageRole,
                RoleCreate,
                RoleDelete,
                RoleEdit,
                PermissionRecords
            };
        }
    }
}
